<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String ctxPath = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ ctxPath + "/";
	String SYSTEM_NAME = "EZMES";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><%=SYSTEM_NAME%></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<base id="baseUrl" href="<%=basePath%>"/>
<link href="<%=basePath %>css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
<link href="<%=basePath %>css/font-awesome.min.css?v=4.3.0" rel="stylesheet">

<!-- Data Tables -->
<link href="<%=basePath %>css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
<link href="<%=basePath %>css/plugins/dataTables/select.bootstrap.css" rel="stylesheet">
<link href="<%=basePath %>css/animate.min.css" rel="stylesheet">
<link href="<%=basePath %>css/style.min.css?v=3.0.0" rel="stylesheet">
</head>
<body>
<!-- head star -->
	<!-- head end -->	
	
	<!-- table star -->
	<div class="row col-lg-12">
		<div class="wrapper wrapper-content animated fadeInUp">
			<div class="ibox">
				<div class="ibox-title"><h5>平台列表</h5>
                   <div class="ibox-tools rboor">
                        <a href="javascript:toAddRoleView()" class="btn btn-primary btn-xs p310"><i class="im-plus"></i> 添加</a>
                        <a href="javascript:toUpdateUserView()" class="btn btn-primary btn-xs p310"><i class="im-pencil2"></i> 编辑</a>
                        <a href="javascript:deleteUser()" class="btn btn-primary btn-xs p310"><i class="im-remove4"></i> 删除</a>
                 <!--   <a href="projects.html" class="btn btn-primary btn-xs p310"><i class="im-spell-check"></i> 批量审核</a>-->       
                        <button id="tb-refresh" onclick="shuaxin()" class="btn btn-primary btn-xs p310"><i class="im-spinner10 fa-spin"></i> 刷新</button>
                   </div>
                </div>
                <div class="ibox-content">
                	<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>平台名称</th>
            </tr>
        </thead>
    </table>
                
                </div>
                
			</div>
		</div>
	</div>
<body>




<!-- 全局js -->
<script src="<%=basePath %>js/jquery-2.1.1.min.js"></script>
<script src="<%=basePath %>js/bootstrap.min.js?v=3.4.0"></script>
<script src="<%=basePath %>js/plugins/jeditable/jquery.jeditable.js"></script>
<!-- Data Tables -->
<script src="<%=basePath %>js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="<%=basePath %>js/plugins/dataTables/dataTables.bootstrap.js"></script>
<script src="<%=basePath %>js/plugins/dataTables/dataTables.select.min.js"></script>
<script src="<%=basePath %>js/plugins/layer/layer.js"></script>
<!-- 自定义js -->
<script src="<%=basePath %>js/content.min.js?v=1.0.0"></script>
</body>
<script type="text/javascript">
var oTable;
$(function(){
	initDataTables();
	rowListen();
});
function initDataTables(){
	oTable = $('#example').DataTable({
		"searching": false,
		"serverSide":true,
		"select"    :true,
		"ajax": $('#baseUrl').attr("href")+"ecommerce/query_allEcommerceByPage",//URL,
		"columns":[
		           {"data":"e_commerce"}
		       ]
	});
}
function rowListen(){
	 $('#example tbody').on( 'click', 'tr', function () {
		 if ( $(this).hasClass('selected') ) {
	            $(this).removeClass('selected');
	        }
	        else {
	        	oTable.$('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	    });
}
function deleteUser(){
	var anSelected = fnGetSelected(oTable);
	if (anSelected.length == 0 ){
		alert("请选择数据");
	}else{
		var id = oTable.row('.selected').data().id;
		$.ajax({
			type:"post",
			data:{"ecommerce.id":id},
			url :$('#baseUrl').attr("href")+"ecommerce/delete_ecommerce",//URL,
			success:function(data){
				if(data == true){
					oTable.row('.selected').remove().draw(true);
				}
			}
		});
	}
}
function fnGetSelected(oTableLocal){
    return oTableLocal.$('tr.selected');
}
function toAddRoleView(){
	layer.open({
		  type: 2,
		  title: '添加平台',
		  area: ['800px', '480px'],
		  fix: false, //不固定
		  maxmin: true,
		  content: $('#baseUrl').attr("href")+"ecommerce/toAddEcommerceView"
		});
}
function shuaxin(){
	oTable.draw();
}
function toUpdateUserView(){
	var anSelected = fnGetSelected(oTable);
	if (anSelected.length == 0 ){
		alert("请选择数据");
	}else{
		var id = oTable.row('.selected').data().id;
		layer.open({
			  type: 2,
			  title: '编辑平台',
			  area: ['800px', '480px'],
			  fix: false, //不固定
			  maxmin: true,
			  content: $('#baseUrl').attr("href")+"ecommerce/toUpdateEcommerce?ecommerce.id="+id
			});
	}
}
function toUpdateRolePermissionView(){
	var anSelected = fnGetSelected(oTable);
	if (anSelected.length == 0 ){
		alert("请选择数据");
	}else{
		var rid = oTable.row('.selected').data().r_id;
		layer.rid = rid;
		layer.open({
			  type: 2,
			  title: '角色赋权',
			  area: ['800px', '480px'],
			  fix: false, //不固定
			  maxmin: true,
			  content: $('#baseUrl').attr("href")+"role/toRolePermissionUpdateView?role.r_id="+rid
			});
	}
}
</script>
</html>
